<div class="linkStyle1" style="margin: 10px 10px 0px 0px;">
	<a href="<?php echo site_url();?>/item">Create New Item</a>
</div>
<?php echo form_open('item/search',array('method' => 'get')); ?>

<div class="header1">Search Options</div>
<div id="options">
	<ul style="display: inline;">
		<li><input type="checkbox" name="name" id="name"
		<?php if($name)echo 'checked';?> /> name</li>
		<li><input type="checkbox" name="barcode" id="barcode"
		<?php if($barcode)echo 'checked';?> /> barcode</li>
		<li><input type="checkbox" name="category" id="category"
		<?php if($category)echo 'checked';?> /> category</li>
		<li><input type="checkbox" name="manufacturer" id="manufacturer"
		<?php if($manufacturer)echo 'checked';?> /> manufacturer</li>
		<li><input type="text" name="search" class="textboxSearch"
			value="<?php echo $search; ?>"
			placeholder="please enter the keyword" maxlength="30" /> <input
			type="submit" id="btn_submit" class="buttonSearch" value="search">
		</li>
	</ul>
</div>

<?php echo form_close(); ?>
<br />
<div class="titleStyle1">Search Results</div>
<?php if (sizeof($result)> 0) {

	echo '<div class="serachResultTable ">';
	echo '<table id="resultTable">';
	echo '<tr>';
	echo '<td style="display:none;"></td>';
	echo '<td>';
	echo 'name';
	echo '</td>';
	echo '<td>';
	echo 'barcode';
	echo '</td>';
	echo '<td>';
	echo 'category';
	echo '</td>';
	echo '<td>';
	echo 'manufacturer';
	echo '</td>';
	echo '<td width="50px">';
	echo 'cost';
	echo '</td>';
	echo '<td width="50px">';
	echo 'price';
	echo '</td>';
	echo '<td width="50px">';
	echo 'current stock';
	echo '</td>';
	echo '<td width="50px">';
	echo 'minimum stock';
	echo '</td>';
	echo '<td width="50px">';
	echo 'promotion unit';
	echo '</td>';
	echo '<td width="50px">';
	echo 'promotion discount';
	echo '</td>';
	echo '<td width="50px">';
	echo 'promotion activated';
	echo '</td>';
	echo '<td width="50px">';
	echo 'active';
	echo '</td>';
	echo '</tr>';

	foreach ($result as $item){
		echo '<tr>';
		echo '<td style="display:none;">';
		echo $item->item_id;
		echo '</td>';
		echo '<td>';
		echo $item->item_name;
		echo '</td>';
		echo '<td>';
		echo $item->item_barcode;
		echo '</td>';
		echo '<td>';
		echo $item->category_name;
		echo '</td>';
		echo '<td>';
		echo $item->manufacturer_name;
		echo '</td>';
		echo '<td>';
		echo $item->item_cost;
		echo '</td>';
		echo '<td>';
		echo $item->item_price;
		echo '</td>';
		echo '<td>';
		echo $item->inventory_current_stock;
		echo '</td>';
		echo '<td>';
		echo $item->inventory_min_stock;
		echo '</td>';
		echo '<td>';
		echo $item->promotion_unit;
		echo '</td>';
		echo '<td>';
		echo $item->promotion_discount;
		echo '</td>';
		echo '<td>';
		if ($item->promotion_active == '1'){
			echo 'yes';
		}else{
			echo 'no';
		}
		echo '</td>';
		echo '<td>';
		if ($item->item_active == '1'){
			echo 'yes';
		}else{
			echo 'no';
		}
		echo '</td>';
		echo '</tr>';
	}

	echo '</table>';
	echo '</div>';
	echo $links;
}else{
	echo '<div class="information">';
	echo 'no result found.';
	echo '</div>';
}
?>

<script>
	$('#btn_submit').click( function(evt){
		if ($('#name').is(':checked') || $('#barcode').is(':checked') || $('#manufacturer').is(':checked') || $('#category').is(':checked')){
		}else{
			evt.preventDefault();
			alert('Please select at least one search option');
		}
	});
	$('#resultTable').find('tr').click( function(){
	  var item_id = $(this).find('td:first').text();
	  if (item_id > 0 )
	  	window.location.replace('<?php echo site_url()?>' + '/item/update/' + item_id);
	});
</script>
